import React, {useState, useEffect} from 'react';
import {useParams} from 'react-router-dom'

export default function UserProfile() {
  const { userid } = useParams()
  const [user, setUser] = useState({
    id: null,
    name: '',
    phone: ''
  })

  useEffect(() => {
    fetch(`https://jsonplaceholder.typicode.com/users/${userid}`).then(resp => resp.json()).then(json => {
      setUser(json)
    })
  }, [userid])

  return <div style={{ marginTop: 20 }}> <div>学员姓名: {user.name}</div><div> 联系方式: {user.phone}</div></div>
}
